package com.zhxq.ai.config;

import com.alibaba.dashscope.audio.ttsv2.SpeechSynthesisParam;
import com.alibaba.dashscope.audio.ttsv2.SpeechSynthesizer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TTSConfiguration {

    @Value("${alibailian.apiKey}")
    private String apiKey;
    @Value("${alibailian.tts.model}")
    private String model;
    @Value("${alibailian.tts.voice}")
    private String voice;

    @Bean
    public SpeechSynthesizer synthesizer() {
        // 请求参数
        SpeechSynthesisParam param =
                SpeechSynthesisParam.builder()
                        .apiKey(apiKey)
                        .model(model) // 模型
                        .voice(voice) // 音色
                        .build();
        return new SpeechSynthesizer(param, null);
    }
}
